<template>
  <div>
    <!-- 面包屑导航 -->
    <el-breadcrumb separator-class="el-icon-arrow-right">
      <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>成绩认定记录</el-breadcrumb-item>
    </el-breadcrumb>
    <el-table size="small" :data="gradeList" highlight-current-row v-loading="loading" border element-loading-text="拼命加载中" style="width: 100%;">
      <!-- <el-table-column align="center" type="selection" width="60">
      </el-table-column> -->
      <el-table-column align="center" prop="newCourseName" label="新课程名称" width="200">
      </el-table-column>
      <el-table-column align="center" prop="newScores" label="新课程分数" width="150">
        <template slot-scope="scope">
          {{scope.row.newScores * 100 | 0}}
        </template>
      </el-table-column>
      <el-table-column align="center" prop="oldScores.courseName" label="旧课程名称" width="150">
      </el-table-column>
      <el-table-column align="center" prop="oldScores.scores" label="旧课程分数" width="150">
        <template slot-scope="scope">
          {{scope.row.oldScores.scores * 100 | 0}}
        </template>
      </el-table-column>
      <el-table-column align="center" prop="oldScores.studentName" label="学生" width="200">
      </el-table-column>
      <el-table-column align="center" label="操作" min-width="200">
        <template slot-scope="scope">
          <el-button type="primary" size="mini" @click="discReal(scope.row)">修改认定</el-button>
          <el-button type="primary" size="mini" @click="deleteReal(scope.row)">删除认定</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <Pagination v-bind:child-msg="pageQuery" :total="total" @callFather="callFather"></Pagination>
    <el-dialog title="成绩修改" :visible.sync="realDialog" width="40%" @click="realDialog=false">
      <el-form label-width="120px" ref="editForm">
        <el-form-item label="新分数：" prop="recordQuery.className">
          <el-input-number v-model="editForm.newScores" :min="0" :max="100"></el-input-number>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button size="small" @click="realDialog=false">取消</el-button>
        <el-button size="small" type="primary" :loading="loading" class="title" @click="discRealApi">确认</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapState } from 'vuex'
import Pagination from '../../components/Pagination'
export default {
  name:'UserDetail',
  data() {
    return {
        realDialog: false,
      gradeList: [], // 列表
      courseList: [],
      pageQuery: {
          termId: '',
        pageNum: 1,
        pageSize: 10
      },
      editForm: {
          id: '',
          newScores: ''
      },
      total: 0,
      loading: false, //是显示加载
    }
  },
  // 注册组件
  components: {
    Pagination
  },
  created() {
    this.getReal()
  },
  computed: {
    ...mapState(['user'])
  },
  methods: {
    /**
     * 修改认定
     */
    discReal (row) {
      this.editForm.id = row.id
      this.realDialog = true
    },
    discRealApi () {
      this.$api.auth.discReal(this.editForm).then(res => {
        if (res.code === 200) {
          this.realDialog = false
          this.$message({
              type: 'success',
              message: '修改成功'
          })
          this.getReal()
        }
      })
    },
    /**
     * 删除认定
     */
    deleteReal (row) {
      let query = {
        id: row.id
      }
      this.$api.auth.deleteReal(query).then(res => {
        if (res.code === 200) {
          this.$message({
              type: 'success',
              message: '删除成功'
          })
          this.getReal()
        }
      })
    },
      /**
     * 获取课程列表
     */
    // getCourseList() {
    //     let query = {
    //         pageNum: 1,
    //         pageSize: -1
    //     }
    //   this.$api.course.getCourseList(query).then(res => {
    //     if (res.code === 200) {
    //       this.courseList = res.data.records
    //     }
    //   }).catch(err => this.loading = false)
    // },
      // search () {
      //     this.managerGetGradeList()
      // },
    /**
     * 认定分数列表
     */
    getReal () {
        this.loading = true
      this.$api.auth.getReal(this.pageQuery).then(res => {
        if (res.code === 200) {
          this.gradeList = res.data.records
          this.total = res.data.total
          this.loading = false
        }
      }).catch(err => this.loading = false)
    },
    /**
     * 分页插件事件
     */
    callFather(parm) {
      this.pageQuery.pageNum = parm.currentPage
      this.pageQuery.pageSize = parm.pageSize
      this.getReal()
    }
  }
}
</script>

<style>
.user-search {
  margin-top: 20px;
}
.userRole {
  width: 100%;
}
.avatar-uploader .el-upload {
  border: 1px dashed #d9d9d9;
  border-radius: 6px;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.avatar-uploader .el-upload:hover {
  border-color: #409EFF;
}
.avatar-uploader-icon {
  font-size: 28px;
  color: #8c939d;
  width: 178px;
  height: 178px;
  line-height: 178px;
  text-align: center;
}
.avatar {
  width: 178px;
  height: 178px;
  display: block;
}
</style>

 
 